package jianzhi_offer;

public class _12_调整数组顺序使奇数位于偶数前面 {
	//复制一个数组保存 顺序信息
	public void reOrderArray(int [] array) {
        int []copy = new int[array.length];
        int left = -1,right = array.length;
        for(int i:array) {
        	if(i%2 == 1) {
        		copy[++left] = i;
        	}else {
        		copy[--right] = i;
        	}
        }
        int i = 0;
        while(i <= left) {
        	array[i] = copy[i];
        	++i;
        }
        int r = array.length-1;
        while(r >= right) {
        	array[i++] = copy[r--];
        }
    }
}
